<?php
    $arr1=[0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
    $arr2=array_rand($arr1,4);
    $arr3=[0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f","A","B","C","D","E","F",0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f","A","B","C","D","E","F"];
    echo '验证码：';
    for($i=0;$i<count($arr2);$i++){
        $arr4=array_rand($arr3,6);
        // echo  '<br>' . 'color:#' . $arr3[$arr4[0]] . $arr3[$arr4[1]] . $arr3[$arr4[2]] . $arr3[$arr4[3]] . $arr3[$arr4[4]] . $arr3[$arr4[5]] . '<br>';//查看颜色
        echo  "<span style=\"color:#{$arr3[$arr4[0]]}{$arr3[$arr4[1]]}{$arr3[$arr4[2]]}{$arr3[$arr4[3]]}{$arr3[$arr4[4]]}{$arr3[$arr4[5]]};\">{$arr1[$arr2[$i]]}</span>";
    }
?>